package com.wly.login.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wly.login.user.mapper.UserMapper;
import com.wly.login.user.entity.User;
import com.wly.login.user.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author wly
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

	@Resource
	private UserMapper userMapper;



	/**
	 * 判断用户是否存在
	 *
	 * @param username 用户名
	 * @author wly
	 * @date 2025-02-24
	 */
	@Override
	public User findByUsername(String username) {
		return this.getOne(new LambdaQueryWrapper<User>()
				.eq(User::getUsername,username));
	}


	/**
	 * 判断手机号是否存在
	 *
	 * @param phone 手机号
	 * @author wly
	 * @date 2025-02-24
	 */
	@Override
	public User findByPhone(String phone) {
		return userMapper.selectOne(
				new LambdaQueryWrapper<User>()
						.eq(User::getPhone,phone));
	}

	/**
	 * 判断手机号是否存在
	 *
	 * @param email 邮箱
	 * @author wly
	 * @date 2025-02-24
	 */
	@Override
	public User findByEmail(String email) {
		return userMapper.selectOne(
				new LambdaQueryWrapper<User>()
						.eq(User::getEmail,email));
	}



}